﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace BLO
{
    /// <summary>
    /// Summary description for Category
    /// </summary>
    public class Category
    {
        DTO.Category info;
        DAO.Category categoryDAO;
        public Category()
        {
            this.categoryDAO = new DAO.Category();
            this.info = new DTO.Category();
        }
           /// <summary>
        /// Category Information.
        /// </summary>
        public DTO.Category Info
        {
            get { return this.info; }
            set { this.info = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="ID"></param>
        public static Category GetCategory(String ID)
        {
            DAO.Category categoryDAO = new DAO.Category();
            Category category = new  Category();
            category.Info = categoryDAO.GetCategory(ID);
            return category;
        }
        /// 
        /// </summary>
        /// <param name="UserID"></param>
        public static List<DTO.Category> GetCategorysOfUser(String UserID)
        {
            DAO.Category categoryDAO = new DAO.Category();
            Category category = new Category();            
            return categoryDAO.GetCategorysOfUser(UserID);            
        }
        /// <summary>
        /// Insert Category information to database.
        /// </summary>
        public int Insert()
        {
            return categoryDAO.InsertCategory(this.info);
        }

        /// <summary>
        /// Update information to database.
        /// </summary>
        public int Update()
        {
            return categoryDAO.UpdateCategory(this.info);
        }

        /// <summary>
        /// Re-get all information from database about this Categorys.
        /// </summary>
        public void Refresh()
        {
            this.info = categoryDAO.GetCategory(this.info.ID.ToString());
        }

        /// <summary>
        /// Delete this news from database.
        /// </summary>
        public int Delete()
        {
            return categoryDAO.DeleteCategory(this.info);
        }
    }
}